package com.example.spring_project.controller;

import com.example.spring_project.service.UserService;
import com.example.spring_project.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "用户注册", tags = {"用户注册接口"})
public class RegisterController {
    private final UserService userService;

    @Autowired
    public RegisterController(UserService userService) {
        this.userService = userService;
    }

    @PostMapping("/register")
    @ApiOperation(value = "用户注册接口", notes = "用于用户注册新账号。")
    public Result<Object> register(@RequestParam @ApiParam(value = "用户名") String uname,
                                   @RequestParam @ApiParam(value = "密码") String password,
                                   @RequestParam @ApiParam(value = "邮箱") String email,
                                   @RequestParam @ApiParam(value = "年龄") int age,
                                   @RequestParam @ApiParam(value = "性别") String gender) {
        // ... Your existing code ...
        return userService.creatorUser(uname, password, email, age, gender);
    }
}
